<!--!
This file is a part of MediaDrop (https://www.mediadrop.video),
Copyright 2009-2018 MediaDrop contributors
For the exact contribution history, see the git revision log.
The source code contained in this file is licensed under the GPLv3 or
(at your option) any later version.
See LICENSE.txt in the main project directory, for more information.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:i18n="http://genshi.edgewall.org/i18n"
      py:with="paginator=c.paginators.comments">
<xi:include href="../master.html" />
<head>
	<title>
		<py:choose test="">
			<py:when test="media_filter_title is None">Comments</py:when>
			<py:otherwise><span py:strip="True" i18n:msg="media_filter_title">Comments for ${media_filter_title}</span></py:otherwise>
		</py:choose>
	</title>
	<script src="${h.url_for('/scripts/third-party/squeezebox-1.1-rc4-yui-compressed.js')}" type="text/javascript"></script>
	<link href="${h.url_for('/admin/styles/squeezebox.css')}" media="screen" rel="stylesheet" type="text/css" />
	<link href="${h.url_for('/admin/styles/comments.css')}" media="screen" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="${h.url_for('/admin/scripts/confirm.js')}"></script>
	<script type="text/javascript" src="${h.url_for('/admin/scripts/tablemgrs.js')}"></script>
	<script type="text/javascript" src="${h.url_for('/admin/scripts/comments.js')}"></script>
	<script type="text/javascript">
		window.addEvent('domready', function(){
			var cm = new CommentMgr({
				editText: '${_('Edit Text').replace("'", "\\'")}',
				editCancel: '${_('Cancel Edit').replace("'", "\\'")}',
				deleteConfirmMgr: {
					header: '${_('Confirm Delete').replace("'", "\\'")}',
					confirmButtonText: '${_('Delete').replace("'", "\\'")}',
					cancelButtonText: '${_('Cancel').replace("'", "\\'")}',
					msg: function(author){ return "${_("Are you sure you want to delete %(name)s's comment?") % dict(name='"+author+"')}"; }
				}
			});
			var table = new BulkTableManager('comment-table', {
				prefix: 'comment-'
			});

			var bulkDelete = new BulkDelete(table, {
				confirmMgr: {
					header: '${_('Confirm Delete').replace("'", "\\'")}',
					msg: function(num){ return '${_('Are you sure you want to delete these %(num)s items?').replace("'", "\\'") % dict(num="'+num+'")}'; },
					confirmButtonText: '${_('Delete').replace("'", "\\'")}',
					cancelButtonText: '${_('Cancel').replace("'", "\\'")}',
				},
				saveUrl: '${h.url_for(action='save_status', status='trash', id='bulk')}'
			});
			$$('bulk-delete').addEvent('click', bulkDelete.onClick.bind(bulkDelete));

			var bulkPublish = new BulkEdit(table, {
				saveUrl: '${h.url_for(action='save_status', status='approve', id='bulk')}',
				onComplete: function(json){
					$$splat(json.ids).each(function(id){
						var row = table.table.getElementById(table.options.prefix + id);
						row.getElement('input.bulk-checkbox').checked = false;
						getCommentInstance(row).updatePublished();
					});
				}
			});
			$('bulk-publish').addEvent('click', bulkPublish.onClick.bind(bulkPublish));
		});
	</script>
</head>
<body class="menu-comments-on">
	<div class="box">
		<div class="box-head clearfix">
			<div id="quicksearch" class="f-rgt">
				${search_form(search)}
			</div>
			<div py:choose="" class="f-lft">
				<h1 py:when="search" i18n:msg="search">Comments that match '${search}'</h1>
				<h1 py:when="media_filter is None">All Comments</h1>
				<h1 py:otherwise="" i18n:msg="search">Comments for ${h.text.truncate('%s' % media_filter_title, 25)}</h1>
			</div>
			<div class="dropdown-wrapper f-lft" style="margin-left:10px;width:130px">
				<div class="dropdown-position">
					<div class="dropdown-box">
						<div class="dropdown-top"><div /></div>
						<div class="dropdown-content">
							<ol class="clearfix">
								<li id="bulk-publish"><span>Publish</span></li>
								<li id="bulk-delete"><span>Delete</span></li>
							</ol>
						</div>
						<div class="dropdown-bottom"><div /></div>
					</div>
				</div>
				<button class="btn inline block dropdown-toggle"><span>Bulk Actions</span></button>
			</div>
		</div>
		<xi:include href="./index-table.html" py:with="comments=comments; edit_form=edit_form;" />
	</div>
</body>
</html>
